#include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define N 20

#define MAX(a, b) (a) > (b) ? (a) : (b)
#define MIN(a, b) (a) < (b) ? (a) : (b)

int main(void)
{
    int arr[N];
    srand(time(NULL));
    
    int max, min, i;
    double ave = 0.0;

    for (i = 0; i < N; i++) {
        arr[i] = rand() % 1000;
        printf("%d ", arr[i]);
    }

    max = min = arr[0]; // 假定第一个数是最值

    for (i = 0; i < N; i++) {
        max = MAX(max, arr[i]);
        min = MIN(min, arr[i]);
        ave += arr[i];
    }
    ave /= N; //求平均值
    printf("\n");
    printf("max = %d, min = %d, ave = %.2f\n", max, min, ave);

    return 0;
}

